package git.soulbgm.upload.service;

import feign.codec.Encoder;
import feign.form.spring.SpringFormEncoder;
import git.soulbgm.upload.pojo.User;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.Map;

/**
 * @author 贺瑞杰
 * @version V1.0
 * @date 2018-09-28 14:47
 * @description @FeignClient(name = "producer") 标明feign调用的微服务名称
 */
@FeignClient(name = "producer", configuration = UploadService.MultipartSupportConfig.class)
public interface UploadService {

    @RequestMapping(value = "/uploadFile", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    String uploadFile(@RequestPart("file") MultipartFile file);

    @Configuration
    class MultipartSupportConfig {
        @Bean
        public Encoder feignFormEncoder() {
            return new SpringFormEncoder();
        }
    }

}
